<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Order.aspx.cs" Inherits="Order" Title="Order" EnableEventValidation="false" %>

<%@ Register assembly="EO.Web" namespace="EO.Web" tagprefix="eo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolder1" Runat="Server">
       
    
    <div id="OrderTable" runat="server">
    <h2>
    <asp:CustomValidator ID="CustomValidator1" runat="server" 
        ErrorMessage="Please login to make an order" 
        onservervalidate="CustomValidator1_ServerValidate" 
        style="text-align: center" ValidationGroup="group1"></asp:CustomValidator></h2>
        <h1>
            <asp:Label ID="lblMessage" runat="server" Text="" EnableViewState="false" Visible="false"></asp:Label></h1>
    <h1>TABLE ORDER</h1>
        <table style="width: 100%;">
            <tr>
                <td style="width: 121px; font-weight:bold"align="right">
                    Date :</td>
                <td style="width: 197px">
                    <eo:DatePicker ID="DatePicker1" runat="server" ControlSkinID="None" 
                        DayCellHeight="15" DayCellWidth="31" DayHeaderFormat="Short" DisabledDates="" 
                        Height="22px" OtherMonthDayVisible="True" SelectedDates="" 
                        TitleFormat="MMMM, yyyy" TitleLeftArrowImageUrl="DefaultSubMenuIconRTL" 
                        TitleRightArrowImageUrl="DefaultSubMenuIcon" VisibleDate="2011-02-01" 
                        Width="152px" AllowMultiSelect="False">
                        <TodayStyle CssText="font-family:Verdana;font-size:8pt;background-image:url('00040401');color:#1176db;" />
                        <SelectedDayStyle CssText="font-family:Verdana;font-size:8pt;background-image:url('00040403');color:Brown;" />
                        <DisabledDayStyle CssText="font-family:Verdana;font-size:8pt;color: gray" />
                        <FooterTemplate>
                            <table border="0" cellPadding="0" cellspacing="5" 
                                style="font-size: 11px; font-family: Verdana">
                                <tr>
                                    <td width="30">
                                    </td>
                                    <td valign="center">
                                        <img src="{img:00040401}"></img></td>
                                    <td valign="center">
                                        Today: {var:today:MM/dd/yyyy}</td>
                                </tr>
                            </table>
                        </FooterTemplate>
                        <CalendarStyle CssText="background-color:white;border-bottom-color:Silver;border-bottom-style:solid;border-bottom-width:1px;border-left-color:Silver;border-left-style:solid;border-left-width:1px;border-right-color:Silver;border-right-style:solid;border-right-width:1px;border-top-color:Silver;border-top-style:solid;border-top-width:1px;color:#2C0B1E;padding-bottom:5px;padding-left:5px;padding-right:5px;padding-top:5px;" />
                        <TitleArrowStyle CssText="cursor: hand" />
                        <DayHoverStyle CssText="font-family:Verdana;font-size:8pt;background-image:url('00040402');color:#1c7cdc;" />
                        <MonthStyle CssText="cursor:hand;margin-bottom:0px;margin-left:4px;margin-right:4px;margin-top:0px;" />
                        <TitleStyle CssText="font-family:Verdana;font-size:8.75pt;padding-bottom:5px;padding-left:5px;padding-right:5px;padding-top:5px;" />
                        <DayHeaderStyle CssText="font-family:Verdana;font-size:8pt;border-bottom: #f5f5f5 1px solid" />
                        <DayStyle CssText="font-family:Verdana;font-size:8pt;" />
                    </eo:DatePicker>
                </td>
                <td>
                    &nbsp;
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                        ErrorMessage="*" ControlToValidate="DatePicker1" ValidationGroup="group1"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td style="width: 121px; font-weight:bold; height: 29px;"align="right">
                    &nbsp;
                    Time :</td>
                <td style="width: 197px; height: 29px;">
                    <asp:DropDownList ID="ddlHour" runat="server" Height="16px">
                    
                        <asp:ListItem Selected="True">0</asp:ListItem>
                        <asp:ListItem>1</asp:ListItem>
                        <asp:ListItem>2</asp:ListItem>
                        <asp:ListItem>3</asp:ListItem>
                        <asp:ListItem>4</asp:ListItem>
                        <asp:ListItem>5</asp:ListItem>
                        <asp:ListItem>6</asp:ListItem>
                        <asp:ListItem>7</asp:ListItem>
                        <asp:ListItem>8</asp:ListItem>
                        <asp:ListItem>9</asp:ListItem>
                        <asp:ListItem>10</asp:ListItem>
                        <asp:ListItem>11</asp:ListItem>
                        <asp:ListItem>12</asp:ListItem>
                        <asp:ListItem>13</asp:ListItem>
                        <asp:ListItem>14</asp:ListItem>
                        <asp:ListItem>15</asp:ListItem>
                        <asp:ListItem>16</asp:ListItem>
                        <asp:ListItem>17</asp:ListItem>
                        <asp:ListItem>18</asp:ListItem>
                        <asp:ListItem>19</asp:ListItem>
                        <asp:ListItem>21</asp:ListItem>
                        <asp:ListItem>22</asp:ListItem>
                        <asp:ListItem>23</asp:ListItem>
                    </asp:DropDownList>
        <asp:Label ID="Label1" runat="server" Text="hh"></asp:Label>                    
                    <asp:DropDownList ID="ddlMinute" runat="server">
                        <asp:ListItem Selected="True">0</asp:ListItem>
                        <asp:ListItem>1</asp:ListItem>
                        <asp:ListItem>2</asp:ListItem>
                        <asp:ListItem>3</asp:ListItem>
                        <asp:ListItem>4</asp:ListItem>
                        <asp:ListItem>5</asp:ListItem>
                        <asp:ListItem>6</asp:ListItem>
                        <asp:ListItem>7</asp:ListItem>
                        <asp:ListItem>8</asp:ListItem>
                        <asp:ListItem>9</asp:ListItem>
                        <asp:ListItem>10</asp:ListItem>
                        <asp:ListItem>11</asp:ListItem>
                        <asp:ListItem>12</asp:ListItem>
                        <asp:ListItem>13</asp:ListItem>
                        <asp:ListItem>14</asp:ListItem>
                        <asp:ListItem>15</asp:ListItem>
                        <asp:ListItem>16</asp:ListItem>
                        <asp:ListItem>17</asp:ListItem>
                        <asp:ListItem>18</asp:ListItem>
                        <asp:ListItem>19</asp:ListItem>
                        <asp:ListItem>21</asp:ListItem>
                        <asp:ListItem>22</asp:ListItem>
                        <asp:ListItem>23</asp:ListItem>
                        <asp:ListItem>24</asp:ListItem>
                        <asp:ListItem>25</asp:ListItem>
                        <asp:ListItem>26</asp:ListItem>
                        <asp:ListItem>27</asp:ListItem>
                        <asp:ListItem>28</asp:ListItem>
                        <asp:ListItem>29</asp:ListItem>
                        <asp:ListItem>30</asp:ListItem>
                        <asp:ListItem>31</asp:ListItem>
                        <asp:ListItem>32</asp:ListItem>
                        <asp:ListItem>33</asp:ListItem>
                        <asp:ListItem>34</asp:ListItem>
                        <asp:ListItem>35</asp:ListItem>
                        <asp:ListItem>36</asp:ListItem>
                        <asp:ListItem>37</asp:ListItem>
                        <asp:ListItem>38</asp:ListItem>
                        <asp:ListItem>39</asp:ListItem>
                        <asp:ListItem>40</asp:ListItem>
                        <asp:ListItem>41</asp:ListItem>
                        <asp:ListItem>42</asp:ListItem>
                        <asp:ListItem>43</asp:ListItem>
                        <asp:ListItem>44</asp:ListItem>
                        <asp:ListItem>45</asp:ListItem>
                        <asp:ListItem>46</asp:ListItem>
                        <asp:ListItem>47</asp:ListItem>
                        <asp:ListItem>48</asp:ListItem>
                        <asp:ListItem>49</asp:ListItem>
                        <asp:ListItem>50</asp:ListItem>
                        <asp:ListItem>51</asp:ListItem>
                        <asp:ListItem>52</asp:ListItem>
                        <asp:ListItem>53</asp:ListItem>
                        <asp:ListItem>53</asp:ListItem>
                        <asp:ListItem>55</asp:ListItem>
                        <asp:ListItem>56</asp:ListItem>
                        <asp:ListItem>57</asp:ListItem>
                        <asp:ListItem>58</asp:ListItem>
                        <asp:ListItem>59</asp:ListItem>
                    </asp:DropDownList>
                    <asp:Label ID="Label2" runat="server" Text="mm"></asp:Label>
                </td>
                <td style="height: 29px">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td style="width: 121px; font-weight:bold"align="right">
                    &nbsp;
                    Number of Tables :</td>
                <td style="width: 197px">
                    <asp:TextBox ID="txtNumberofTables" runat="server" Width="50px"></asp:TextBox>
                </td>
                <td>
                    &nbsp;
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                        ErrorMessage="*" ControlToValidate="txtNumberofTables" Display="Dynamic" 
                        ValidationGroup="group1"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                        ControlToValidate="txtNumberofTables" Display="Dynamic" 
                        ErrorMessage="Number of Tables must be an integer" 
                        ValidationExpression="\d+" ValidationGroup="group1"></asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td style="width: 121px; font-weight:bold"align="right">
                    Note :</td>
                <td style="width: 197px">
                    <asp:TextBox ID="txtNote" runat="server" Height="68px" TextMode="MultiLine"></asp:TextBox>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td style="width: 121px; font-weight:bold"align="right">
                    &nbsp;</td>
                <td style="width: 197px">
                    <asp:Button ID="btnSend" runat="server" Text="Send" onclick="btnSend_Click" 
                        style="height: 26px" ValidationGroup="group1" 
                        oncommand="btnSend_Command" />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
    </div>
    
    <div runat="server" id="MemberOnly" visible="false">
    <img alt="" onclick="ShowHide('PrevOrders')" style="border:none" src="images/icon_expanded.gif" id="PrevOrdersImage"/>Previous Orders
        <div id="PrevOrders" style="display:block">
            <asp:Repeater ID="rptPrevOrders" runat="server" 
                onitemdatabound="rptPrevOrders_ItemDataBound">
                <HeaderTemplate><table border="1">
                    <tr>
                        <th align="left">Menu</th>
                        <th align="left">Price</th>
                        <th align="left">Tables</th>
                        <th align="left">Total Price</th>
                        <th align="left">Date</th>
                        <th align="left">Time</th>
                        <th align="left">Note</th>
                        <th align="left">Status</th>
                    </tr>
                </HeaderTemplate>
                <ItemTemplate>
                <asp:Label ID="lblID" runat="server" Visible="false" Text='<%#DataBinder.Eval(Container.DataItem,"ID") %>' />
                    <tr>
                        <td><asp:Label ID="lblMenu" runat="server" /></td>
                        <td><asp:Label ID="lblPrice" runat="server" /></td>
                        <td><%#DataBinder.Eval(Container.DataItem,"Quantity") %></td>
                        <td><%#DataBinder.Eval(Container.DataItem,"Price") %></td>
                        <td><asp:Label ID="lblOrderDate" runat="server" /></td>
                        <td><asp:Label ID="lblOrderTime" runat="server" /></td>
                        <td><%#DataBinder.Eval(Container.DataItem,"Note") %></td>
                        <td><%#DataBinder.Eval(Container.DataItem,"Status") %></td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate></table></FooterTemplate>
            </asp:Repeater>  
            
            <br />
                         
            <asp:Repeater ID="rptPrevOrdersPages" Runat="server" OnItemCommand="rptPages_ItemCommand">
      <HeaderTemplate>
      <table cellpadding="0" cellspacing="0" border="0">
      <tr>
         <td><b>Page:</b>&nbsp;</td>
         <td>
      </HeaderTemplate>
      <ItemTemplate>
         <asp:LinkButton ID="btnPage" CausesValidation="false"
                         CommandName="Page"
                         CommandArgument="<%#
                         Container.DataItem %>"
                         Runat="server"><%# Container.DataItem %>
                         </asp:LinkButton>&nbsp;
      </ItemTemplate>
          <FooterTemplate>
             </td>
          </tr>
          </table>
          </FooterTemplate>
      </asp:Repeater>
        </div>
    </div>
    
    <div runat="server" id="AdminOnly" visible="false">
        <center>
        <h1>ORDERS</h1>
        Status : <asp:DropDownList ID="ddlOrderStatus" runat="server" 
            onselectedindexchanged="ddlOrderStatus_SelectedIndexChanged" 
            AutoPostBack="True">
            <asp:ListItem Value="All" Selected="True">All</asp:ListItem>
            <asp:ListItem Value="Waiting">Waiting</asp:ListItem>
            <asp:ListItem Value="Approved">Approved</asp:ListItem>
            <asp:ListItem Value="Refused">Refused</asp:ListItem>
        </asp:DropDownList></center>
        <asp:Repeater ID="rptOrders" runat="server" 
            onitemdatabound="rptOrders_ItemDataBound">
            <HeaderTemplate><table border="1">
                <tr>
                    <th align="left">Customer Name</th>
                    <th align="left">Menu</th>
                    <th align="left">Price</th>
                    <th align="left">Tables</th>
                    <th align="left">Total Price</th>
                    <th align="left">Date</th>
                    <th align="left">Time</th>
                    <th align="left">Note</th>
                    <th align="left">Status</th>
                </tr>
            </HeaderTemplate>
            <ItemTemplate>
            <asp:Label ID="lblID" runat="server" Visible="false" Text='<%#DataBinder.Eval(Container.DataItem,"ID") %>' />
                <tr>
                    <td><asp:Label ID="lblCustomerName" runat="server" /></td>
                    <td><asp:Label ID="lblMenu" runat="server" /></td>
                    <td><asp:Label ID="lblPrice" runat="server" /></td>
                    <td><%#DataBinder.Eval(Container.DataItem,"Quantity") %></td>
                    <td><%#DataBinder.Eval(Container.DataItem,"Price") %></td>
                    <td><asp:Label ID="lblOrderDate" runat="server" /></td>
                    <td><asp:Label ID="lblOrderTime" runat="server" /></td>
                    <td><%#DataBinder.Eval(Container.DataItem,"Note") %></td>
                    <td><asp:Label ID="lblStatus" runat="server" />
                    <asp:Button ID="btnAccept" runat="server" Text="Approve" CommandName="Approved" CommandArgument='<%#Eval("ID") %>' CausesValidation="false" OnCommand="ChangeOrderStatus" Visible="false" />
                    <asp:Button ID="btnRefuse" runat="server" Text="Refuse" Visible="false" CommandName="Refused" CommandArgument='<%#Eval("ID") %>' CausesValidation="false" OnCommand="ChangeOrderStatus" />
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate></table></FooterTemplate>
        </asp:Repeater>  
        
            <br />
                         
            <asp:Repeater ID="rptOrderPages" Runat="server" OnItemCommand="rptPages_ItemCommand">
      <HeaderTemplate>
      <table cellpadding="0" cellspacing="0" border="0">
      <tr>
         <td><b>Page:</b>&nbsp;</td>
         <td>
      </HeaderTemplate>
      <ItemTemplate>
         <asp:LinkButton ID="btnPage" CausesValidation="false"
                         CommandName="Page"
                         CommandArgument="<%#
                         Container.DataItem %>"
                         Runat="server"><%# Container.DataItem %>
                         </asp:LinkButton>&nbsp;
      </ItemTemplate>
          <FooterTemplate>
             </td>
          </tr>
          </table>
          </FooterTemplate>
      </asp:Repeater>
    </div>
</asp:Content>

